/*点击验证码进行刷新*/
function flushCode() {
    document.getElementById("getCode").src = "http://localhost:8086/captcha/captchaImage?type=math";
}

function zhuce() {
    window.location.href = "../html/userRegister.html"
}
layui.use("layer")
/*登录按钮操作*/
function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    // if (!reg.test(password)) {
    //     alert("您输入的密码格式不正确！");
    //     return;
    // }
    let data = {
        username: username,
        password: password,
        code: code
    };
    console.log(data);
    let result = myAjax('/login/verify', 'post', data);
    console.log(result);
    if (result.code===200){
        let bearer = result.data.tokenHead;
        let token = result.data.access_token;
        $.cookie("token",bearer+token);
        localStorage.setItem("jwt",bearer+token)
        location.assign("/html/manage.html");
    }else if (result.code===404){
        layer.msg("用户名或密码错误！请重新输入");
    }else {
        layer.msg("出了意料之外的错误，请稍后再试");
    }
    /*
           * 逻辑：通过数据判断用户信息是否匹配和正确，如果是跳转到下个界面，如果不正确提示错误请重新输入
           * */

}
